<admintpl file="header" />
<style>
	
	.btn-con .btn{
		margin: 5px;
	}	

</style>
</head>

<body class="J_scroll_fixed">
	
	<div class="wrap J_check_wrap">
		<ul class="nav nav-tabs">
	        <li class="active"><a href="#A" data-toggle="tab">基本属性</a></li>
	        <li><a href="#D" data-toggle="tab">归类设置</a></li>
	        <li><a href="#B" data-toggle="tab">SEO设置</a></li>
	        <li><a href="#C" data-toggle="tab">模板设置</a></li>
	    </ul>
		<form class="form-horizontal J_ajaxForm" name="myform" id="myform" action="{:u('AdminTerm/add_post')}" method="post">
			<div class="tabbable">
		        <div class="tab-content">
		          <div class="tab-pane active" id="A">
		          		<table cellpadding="2" cellspacing="2" width="100%">
							<tbody>
								<tr style="display:none">
									<td width="140">上级:</td>
									<td><select name="parent" class="normal_select">
											<option value="0">作为一级分类</option>
											{$terms_tree}
									</select></td>
								</tr>
								<tr>
									<td>名称:</td>
									<td><input type="text" class="input" name="name" value=""><span class="must_red">*</span></td>
								</tr>
								<tr>
									<td>描述:</td>
									<td><textarea name="description" rows="5" cols="57"></textarea></td>
								</tr>
								<tr>
									<td>类型:</td>
									<td><select name="taxonomy">
											<foreach name="taxonomys" item="vo">
									        	<option value="{$key}">{$vo}</option>
											</foreach>
									</select></td>
								</tr>
							</tbody>
						</table>
		          </div>
		          <div class="tab-pane" id="B">
		          		<table cellpadding="2" cellspacing="2" width="100%">
							<tbody>
								<tr>
									<td width="180">SEO标题:</td>
									<td><input type="text" class="input" name="seo_title" value=""></td>
								</tr>
								<tr>
									<td>SEO关键字:</td>
									<td><input type="text" class="input" name="seo_keywords" value=""></td>
								</tr>
								<tr>
									<td>SEO描述:</td>
									<td><textarea name="seo_description" rows="5" cols="57"></textarea></td>
								</tr>
							</tbody>
						</table>
		          </div>
		          <div class="tab-pane" id="C">
		          		<table cellpadding="2" cellspacing="2" width="100%">
							<tbody>
								<php>$tpl_list=sp_admin_get_tpl_file_list();</php>
								<tr>
									<td width="180">列表页模板:</td>
									<td>
										<php>
											$list_tpls=$tpl_list;
											unset($list_tpls['list']);
										</php>
					              		<select  class="normal_select" name="list_tpl">
					              			<option value="list">list{:C("TMPL_TEMPLATE_SUFFIX")}</option>
					              			<foreach name="list_tpls" item="vo">
					              				<option value="{$vo}">{$vo}{:C("TMPL_TEMPLATE_SUFFIX")}</option>
					              			</foreach>
					              		</select>
									</td>
								</tr>
								<tr>
									<td>单文章模板:</td>
									<td>
										<php>
											$article_tpls=$tpl_list;
											unset($article_tpls['article']);
										</php>
					              		<select  class="normal_select" name="one_tpl">
					              			<option value="article">article{:C("TMPL_TEMPLATE_SUFFIX")}</option>
					              			<foreach name="article_tpls" item="vo">
					              				<option value="{$vo}">{$vo}{:C("TMPL_TEMPLATE_SUFFIX")}</option>
					              			</foreach>
					              		</select>
									</td>
								</tr>
							</tbody>
						</table>
		          </div>
		                <div class="tab-pane" id="D">
					<form method="post" class="J_ajaxForm" action="{:U('AdminTerm/listorders')}">
					    <div class="table-actions">
					      <input  type="text" class="input inputbox" id="ctext" name="name" placeholder="请输入分类名称">
					    <button id="fename" class="btn btn-primary btn-small" type="button">添加分类</button>
					    </div>
					    <table class="table table-hover table-bordered table-list">
					        <thead>
					            <tr>
					               
					                <th width="50">序号</th>
					                <th>分类名称</th>
					                <th>分类项列表</th>

					            </tr>
					        </thead>
					        <tbody id="tbody">
					            
					        </tbody>
					    </table>
					</form>

		          </div>
		        </div>
		    </div>
		     <div class="form-actions">
		           <button class="btn btn-primary btn_submit J_ajax_submit_btn"type="submit">提交</button>
		      		<a class="btn" href="{:U('AdminTerm/index')}">返回</a>
		      </div>
		</form>
	</div>
	<script type="text/javascript" src="__ROOT__/statics/js/common.js"></script>
	<script>
 var num=1;
	$('#fename').on('click', function (e) {
	 e.preventDefault();
	  var btn = $(this),
          form = btn.parents('form.J_ajaxForm');
		 
          btn.parent().find('span').remove();
		  var ctext=form.find('input.inputbox').val();
           if (ctext!='') {
           		// alert(form.find('input.inputbox').val());
				  
				   $('<tr><td>'+num+'</td><td>'+ctext+'</td><td><div class="btn-con"><input class="input" name="clist[]" type="text"  placeholder="点击右边按钮添加项" /><button class="btn-fl-add btn btn-primary btn-small" type="button">添加</button><button class="btn-fl-del btn btn-warning btn-small" type="button">删除</button></div></td></tr>').appendTo(form.find('table tbody')).fadeIn('fast');
       
		   num=num+1;
		  
		}else{
           	 $('<span class="tips_error">请输入分类名称</span>').appendTo(btn.parent()).fadeIn('fast');
           }

		});


		$("#tbody").on("click",".btn-fl-add", function() {
		$('<div class="btn-con"><input class="input" name="clist[]" type="text"  placeholder="点击右边按钮添加项" /><button class="btn-fl-add btn btn-primary btn-small" type="button">添加</button><button class="btn-fl-del btn btn-warning btn-small" type="button">删除</button></div>').appendTo($(this).parent().parent()).fadeIn('fast');
});

		$("#tbody").on("click",".btn-fl-del", function() {
		
			if($(this).parent().parent().children('.btn-con').length>1){
					
$("this").parent().remove().fadeOut('fast');
			}else{
				$('<span class="tips_error">分类项不能少于一项。</span>').appendTo($(this).parent()).fadeIn('fast');	
			};
		
});




	
	</script>
</body>
</html>